import time
from selenium import webdriver
from selenium.webdriver.common.by import By


# 七月 业务流程 二
driver=webdriver.Edge()
driver.maximize_window()
driver.get('http://10.59.9.12:7001/')
# 登录
driver.find_element(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a').click()
time.sleep(5)
driver.find_element(By.NAME,'username').send_keys('13811033962')
time.sleep(3)
driver.find_element(By.NAME,'password').send_keys('123456')
time.sleep(8)
driver.find_element(By.CLASS_NAME,'finish-btn').click()
time.sleep(3)
#切换窗口
driver.switch_to.window(driver.window_handles[-1])
time.sleep(5)
# 商品搜索
driver.find_element(By.CLASS_NAME,'search-input').send_keys("非洲之心")
time.sleep(3)
# 按钮
driver.find_element(By.CLASS_NAME,'search-input-btn').click()
time.sleep(3)
# 商品详情
driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[1]/ul/li/div[1]/span/a/img').click()
time.sleep(3)
# 立即购买
driver.find_element(By.CSS_SELECTOR,'.buy-cart').click()
time.sleep(3)
# 购买成功
driver.find_element(By.CLASS_NAME,'ask-btn').click()
time.sleep(3)